﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using ElfTyping.General;

namespace ElfTyping.States.GameState.Entities
{    
    public class BasicEnemy : Enemy
    {
        private float timeLeftWaitingToAttack = 1f;

        public BasicEnemy(GameScript script, Vector2 centerPosition, EnemyDifficulty difficulty)
            : base(script, centerPosition, difficulty)
        {
            switch (difficulty)
            {
                case EnemyDifficulty.Easy:
                    LoadAnimations(@"Textures\GameState\Soldier_Green");
                    MaximumHealth = 10;
                    Damage = 1;
                    Experience = 1;
                    BaseSpeed = random.Next(30, 60);
                    Word = GetNewWord(3);
                    break;

                case EnemyDifficulty.Medium:
                    LoadAnimations(@"Textures\GameState\Soldier_Purple");
                    MaximumHealth = 15;
                    Damage = 2;
                    Experience = 3;
                    BaseSpeed = random.Next(20, 50);
                    Word = GetNewWord(5);
                    break;

                case EnemyDifficulty.Hard:
                    LoadAnimations(@"Textures\GameState\Soldier_Red");
                    MaximumHealth = 20;
                    Damage = 3;
                    Experience = 5;
                    BaseSpeed = random.Next(25, 35);
                    Word = GetNewWord(7);
                    break;
            }
        }

        public override void Tick(float dt)
        {
            if (IsActive || timeLeftWaitingToAttack <= 0)
            {
                MoveCenter(CenterPosition.X + MoveSpeed * dt, CenterPosition.Y);
            }
            else
            {
                timeLeftWaitingToAttack -= dt;
            }

            CurrentAnimation = IsActive ? MovingAnimation : AttackingAnimation;

            base.Tick(dt);
        }
    }
}
